import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Show from "../views/Show";
import Ele from "../views/Ele";
import Create from "../views/Create";
import Delete from "../views/Delete";
import Update from "../views/Update";
import Search from "../views/Search";
import Browse from "../views/Browse";

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    name: 'Main',
    component: Ele,
    //redirect: '/browse',
    children: [
      {
        path: '/browse',
        name: '浏览',
        component: Browse
      },
      {
        path: '/create',
        name: '新增',
        component: Create
      },
      {
        path: '/delete',
        name: '删除',
        component: Delete
      },
      {
        path: '/update',
        name: '修改',
        component: Update
      },
      {
        path: '/search',
        name: '查找',
        component: Search
      }
    ]
  },
  {
    path: '/home',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path: '/show',
    component: Show
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
